#include <iostream>
using std::cout;
using std::endl;

class Base{
public:
    Base(long x)
    : _base(x)
    {
        cout << "Base()" << endl;
    }

    void print() const{
        cout << "Base::_base:" << _base << endl;
        cout << "Base::_data:" << _data << endl;
    }
    
    long _data = 100;
private:
    long _base;
};

class Derived
: public Base
{
public:
    Derived(long base,long derived)
    : Base(base)//创建基类子对象
    , _derived(derived)
    {
        cout << "Derived()" << endl;
    }

    int print(int x) const{
        cout << "Derived::_derived:" << _derived << endl;
        cout << "Derived::_data:" << _data << endl;
        return x;
    }

    
    double _data = 19.7;
private:
    long _derived;

};

void test1(){
    Derived d1(7,8);
    d1.print(2);//隐藏
    d1.Base::print();
}


void test0(){
    /* cout << sizeof(Base) << endl; */
    /* cout << sizeof(Derived) << endl; */
    Base b1(30);
    cout << b1._data << endl;
    cout << endl;


    Derived d1(3,4);
    cout << d1._data << endl;//隐藏
    cout << d1.Base::_data << endl;
    

}

int main(void){
    test1();
    return 0;
}
